#include "message.h"

namespace IAlib
{

Message::Message()
{
    m_type = MSG_TYPE_INFORM;
    m_sender = "";
}
//-----------------------------------------------------------
Message::Message( const MessageType message_type )
{
    m_type = message_type;
    m_sender = "";
}
//-----------------------------------------------------------
Message::Message(const Message & message )
{
    m_type = message.m_type;
    m_facts = message.m_facts;
    m_sender = message.m_sender;
    m_receiver = message.m_receiver;
}


/////////////////////////////////////////////////////////////////////

void Message::addFact( const Fact&  fact )
{
   m_facts.insert(m_facts.size(), fact);
}

//////////////////////////////////////////////////////////////////////////

void Message::removeFact(const QString& FactName)
{
    int i = 0;
    while ( i < m_facts.size() )
    {
        if (m_facts[i].getFactName() == FactName)
        {
            break;
        }
        i++;
    }
    m_facts.removeAt(i);
}

void Message::removeAllFact()
{
    m_facts.clear();
}

/////////////////////////////////////////////////////////////////////////

QList<Fact> Message::getFacts() const
{
    return m_facts;
}

Message::MessageType Message::getType() const
{
    return m_type;
}

QList<QString> Message::getReceivers() const
{
    return m_receiver;
}

QString Message::getSender() const
{
    return m_sender;
}

void Message::setType(const Message::MessageType type)
{
    m_type = type;
}

void Message::addReceiver(const QString &receiver)
{
    m_receiver.insert(m_receiver.end(),receiver);
}

void Message::setSender(const QString &sender)
{
    m_sender = sender;
}

}
